package com.yequan.work;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author yequan
 * @date 2021/06/21 15:31
 **/
public class Entity implements Comparable<Entity> {

    private String pst;

    private String name;

    private int age;

    public Entity() {
    }

    public Entity(String pst, String name, int age) {
        this.pst = pst;
        this.name = name;
        this.age = age;
    }

    public String getPst() {
        return pst;
    }

    public void setPst(String pst) {
        this.pst = pst;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Entity{" +
                "pst='" + pst + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Entity o) {
        int compareTo = this.getPst().compareTo(o.getPst());
        System.out.println(compareTo);
        return compareTo;
    }

//    @Override
//    public boolean equals(Object anObject) {
//        return this == anObject;
//    }

    public static void main(String[] args) {
        Entity entity1 = new Entity("20210618134500", "tom", 12);
        Entity entity2 = new Entity("20210918134500", "jerry", 23);
        Entity entity3 = new Entity("20200618134500", "lily", 9);
        Entity entity4 = new Entity("20210818134500", "merry", 19);
        List<Entity> entities = new ArrayList<>();
        entities.add(entity1);
        entities.add(entity2);
        entities.add(entity3);
        entities.add(entity4);
        System.out.println(entities);
        Collections.sort(entities);
        System.out.println(entities);
    }
}
